﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BLL;
using DTO;
namespace HotelManagement.ModKhachSan
{
    public partial class QL_KhachSan : System.Web.UI.Page
    {
        protected static KindsRoom kindroom = KindsRoom.ALL;
        private static bool isFloor = false;
        private static int status = 10;
        protected static string strIDStatusRoom = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            Rec_RoomBLL roomBl = new Rec_RoomBLL();
            DataTable tb = roomBl.SelectAll();
            this.rptTabRooms.DataSource = tb;
            this.rptTabRooms.DataBind();
        }

        protected void lbtnAllRooms_Click(object sender, EventArgs e)
        {

        }

        protected void lbtnSigleRooms_Click(object sender, EventArgs e)
        {

        }

        protected void lbtnDoubleRooms_Click(object sender, EventArgs e)
        {

        }

        protected void lbtnLuxuryRooms_Click(object sender, EventArgs e)
        {

        }

        protected void lbtnVipRooms_Click(object sender, EventArgs e)
        {

        }

        protected void lbtnRefeshRoom_Click(object sender, EventArgs e)
        {

        }

        protected void lbtnStatusAll_Click(object sender, EventArgs e)
        {

        }

        protected void lbtnStatusEmpty_Click(object sender, EventArgs e)
        {

        }

        protected void lbtnStatusBook_Click(object sender, EventArgs e)
        {

        }

        protected void lbtnStatusLodge_Click(object sender, EventArgs e)
        {

        }

        protected void lbtnStatusBookAdd_Click(object sender, EventArgs e)
        {

        }

        protected void lbtnStatusDirty_Click(object sender, EventArgs e)
        {

        }

        protected void lbtnStatusMainte_Click(object sender, EventArgs e)
        {

        }

        protected void ddlFloor_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void ddlBuilding_SelectedIndexChanged(object sender, EventArgs e)
        {
            //try
            //{
            //    if (this.ddlBuilding.SelectedValue.ToString() == "0")
            //    {
            //        this.ddlFloor.Items.Clear();
            //        isFloor = false;
            //    }
            //    else
            //    {
            //        DataTable tbl = new LT_TangLau().GetDataTable(8, Convert.ToInt64(this.ddlBuilding.SelectedValue.ToString()));
            //        this.ddlFloor.Items.Clear();
            //        if (tbl != null)
            //        {
            //            ProcessControl.FillDataInDropDownList(ref this.ddlFloor, tbl, "IDTL", "TenTL");
            //            this.ddlFloor.Items.Insert(0, new ListItem("Floor", "0"));
            //        }
            //        isFloor = true;
            //    }
            //    this.Reload();
            //}
            //catch
            //{
            //}
            //finally
            //{
            //    this.pnlFloor.Visible = isFloor;
            //}
        }

        protected void rptTabRooms_ItemCommand(object source, RepeaterCommandEventArgs e)
        {

        }
        private void Reload()
        {
            Rec_RoomBLL room = new Rec_RoomBLL();
            try
            {
                string strSQL = "select IDRoom,RoomName,(case Status when 0 then N'room-empty' when 1 then N'room-book' when 2 then N'room-Lodge' when 3 then N'room-Dirty' when 4 then N'room-BookAdd' when 5 then N'room-Mainte' end) as 'cssCls' from Rec_Room where 1=1";
                if ((this.ddlBuilding.SelectedValue.ToString() != "0") && IsNumeric.IsInteger(this.ddlBuilding.SelectedValue.ToString().Trim()))
                {
                    strSQL = strSQL + " and IdFloor in (select IDTL from Rec_Floor where IdBuiding=" + this.ddlBuilding.SelectedValue.ToString() + ")";
                }
                if (((this.ddlFloor.Items.Count > 0) && (this.ddlFloor.SelectedValue.ToString() != "0")) && IsNumeric.IsInteger(this.ddlFloor.SelectedValue.ToString().Trim()))
                {
                    strSQL = strSQL + " and IdFloor=" + this.ddlFloor.SelectedValue.ToString();
                }
                if (!StatusRooms.ALL.Equals(Enum.Parse(typeof(StatusRooms), status.ToString())))
                {
                    strSQL = strSQL + " and Status=" + status.ToString();
                }
                else
                {
                    strIDStatusRoom = this.lbtnStatusAll.ClientID;
                }
                if (!KindsRoom.ALL.Equals(kindroom))
                {
                    strSQL = strSQL + " and IDLP=(select IdRoomType from Rec_TypeRoom where IdRoomType='" + kindroom.ToString() + "')";
                }
                strSQL = strSQL + " Order by RoomName";
                DataTable tbl = room.SelectAll(strSQL);
                this.rptTabRooms.DataSource = tbl;
                this.rptTabRooms.DataBind();
            }
            catch
            {
            }
        }


    }
}